package com.zyh.day01

import scala.collection.parallel.immutable

object ForTest {
  def main(args: Array[String]): Unit = {
    //val inclusive1: Range.Inclusive = 0.to(10)//包含0-10
    //val inclusive2: Range.Inclusive = 0 to(10)//包含0-10
    //val inclusive3: Range.Inclusive = 0.to(10, 2)//步长为2
    //val range1: Range = 0.until(10)//包含0-9
    //val range2: Range = 0 until(10)//包含0-9
    //val range3: Range = 0.until(10,2)//步长为2
    for(i <- 1 to 10 if i != 5 && i != 8){
      println(s"i = $i")
    }

    for{
      a <- 0 until 10
      j = a + 1
      if(a%2==0 && j%3==0)
    }{
      println(s"a = ${a}")
    }

    //双层循环
    for(i <- 0 to 10 ; j <- 0 to 10){
      println(s"i,j = $i,$j")
    }

    //for推导式
    for (i <- 0 to 10) yield i * 10
  }
}
